package com.sugon.service.impl;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.RandomUtil;
import com.sugon.dao.KnowFileDao;
import com.sugon.entity.KnowFileEntity;
import com.sugon.service.KnowFileService;
import com.sugon.utils.Constant;
import com.sugon.utils.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 知识库关联附件Service实现类
 *
 * @author sugon
 * @date 2019-07-11 08:51:52
 */
@Service("knowFileService")
public class KnowFileServiceImpl implements KnowFileService {
    @Autowired
    private KnowFileDao knowFileDao;

    @Override
    public KnowFileEntity queryObject(String id) {
        return knowFileDao.queryObject(id);
    }

    @Override
    public List<KnowFileEntity> queryList(Map<String, Object> map) {
        return knowFileDao.queryList(map);
    }

    @Override
    public int queryTotal(Map<String, Object> map) {
        return knowFileDao.queryTotal(map);
    }

    @Override
    public int save(KnowFileEntity knowFile) {
        knowFile.setId(RandomUtil.randomString(32));
        knowFile.setDelFlag(Constant.IS_NOT_DEL_INT);
        knowFile.setCreateDate(DateUtil.date());
        knowFile.setCreateUser(ShiroUtils.getUserId());
        return knowFileDao.save(knowFile);
    }

    @Override
    public int update(KnowFileEntity knowFile) {
        return knowFileDao.update(knowFile);
    }

    @Override
    public int delete(String id) {
        return knowFileDao.delete(id);
    }

    @Override
    public int deleteBatch(String[] ids) {
        return knowFileDao.deleteBatch(ids);
    }
}
